package test09;


import java.util.function.Consumer;

/**
 * @Author czl
 * @Date 2024-04-11
 */
public class MainTest {
    public static void main(String[] args) {
        Student[] student = {
                new Student("张三三",17),
                new Student("李四",60),
                new Student("王五",10),
        };

        Consumer<Student[]> consumer = (stuList) ->{
            System.out.println("姓李的学生信息：");

            for (Student student1 : stuList) {
                if (student1.getName().startsWith("李")){
                    System.out.println(student1);
                }
            }
        };


        Consumer<Student[]> consumer1 = (stuList) -> {
            System.out.println("名字带三个字的学生信息：");
            for (Student student1 : stuList) {
                if (student1.getName().length() == 3){
                    System.out.println(student1);
                }
            }
        };


        Consumer<Student[]> consumer2 = (stuList) ->{
            System.out.println("年龄大于18岁的学生信息：");
            for (Student student1 : stuList) {
                if (student1.getAge() >18){
                    System.out.println(student1);
                }
            }
        };


        consumer.andThen(consumer1).andThen(consumer2).accept(student);
    }
}
